/*
 * @Author: chendeji
 * @Date: 2021-11-16 11:31:56
 * @LastEditTime: 2021-11-16 11:55:48
 * @Description: 
 * @FilePath: \copy_gsy_github_app_flutter\lib\common\net\code.dart
 * 联系方式：
 * wx: melody_2009
 * qq: 7815171323 
 */
///错误编码
class Code {
  ///网络错误
  static const NETWORK_ERROR = -1;

  ///网络超时
  static const NETWORK_TIMEOUT = -2;

  ///网络返回数据格式化一次
  static const NETWORK_JSON_EXCEPTION = -3;

  ///Github APi Connection refused
  static const GITHUB_API_REFUSED = -4;

  static const SUCCESS = 200;

  static errorHandleFunction(code, message, noTip) {
    if (noTip) {
      return message;
    }
    if (message != null &&
        message is String &&
        (message.contains("Connection refused") ||
            message.contains("Connection reset"))) {
      code = GITHUB_API_REFUSED;
    }
    //需要将消息传递出去
    // eventBus.fire(new HttpErrorEvent(code, message));
    return message;
  }
}
